﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Diagnostics;
using MetroHoo.External.Yahoo;

namespace YahooExample
{
    public partial class MainPage : PhoneApplicationPage
    {
        YahooClient client;
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            if (String.IsNullOrEmpty(AppKeys.kYahooAppKey) || String.IsNullOrEmpty(AppKeys.kYahooAppSecret))
                throw new NotImplementedException("You need to add your keys");

            client = new YahooClient(AppKeys.kYahooAppKey, AppKeys.kYahooAppSecret);
        }
        private void clickMeButton_Click(object sender, RoutedEventArgs e)
        {
            testClient();
        }

        private async void testClient()
        {
            var authd = await client.AuthorizeAsync(@"http://jaykimble.net");
            Debug.WriteLine("auth result: " + authd);

            // NOTE: this call is not currently working (we are having problems calling http methods in the Yahoo API (HTTPS may work fine)
            var result = await client.GetLeagues(); 
            Debug.WriteLine("get Leagues result: " + result);
        }
    }
}